﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CSharp;
using System.CodeDom.Compiler;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {

            CSharpCodeProvider p = new CSharpCodeProvider();
            CompilerParameters param = new CompilerParameters(new string[] { "System.dll" });
            string s = "namespace __ns{public class AAA{ public string name{get{return \"abab\";}} }}";
            CompilerResults rel = p.CompileAssemblyFromSource(param, s);
            Type t = rel.CompiledAssembly.GetType("__ns.AAA");

            object o1 = t.GetConstructor(System.Type.EmptyTypes).Invoke(null);
            Console.WriteLine( t.GetProperty("name").GetValue(o1, null).ToString());


            List<People> listp = new List<People>();
            listp.Add(new People(){name="aa",age="1"});
            var x = from item in listp
                    select new { item.age,item.name };
            var y = x.ToList();
            var dd = y.Select(
                 o => new { o.age, o.name });
            Console.ReadLine();
        }
    }

    class People
    {
        public string name;
        public string age;
    }
}
